using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using UnityEngine;

public class lesson4
{
 public   SerilaizerableDictionary<string,int> dic; 

}

public class Lesson4 : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
       lesson4 l=new lesson4();
        lesson4 l2;
        l.dic = new SerilaizerableDictionary<string, int>();
        l.dic.Add("1", 1);
        l.dic.Add("2", 2);
        l.dic.Add("3", 3);
        string path = Application.persistentDataPath + "/Lesson4Test.xml";
        using (StreamWriter w=new StreamWriter(path))
        {
            XmlSerializer x=new XmlSerializer(typeof(lesson4));
            x.Serialize(w, l);
        }
        using (StreamReader w = new StreamReader(path))
        {
            XmlSerializer x = new XmlSerializer(typeof(lesson4));
            l2= x.Deserialize(w) as lesson4;
        }
        foreach(KeyValuePair<string,int>kv in l2.dic)
        {
            Debug.Log(kv.Key);
            Debug.Log(kv.Value);
            Debug.Log("-----------------------------------------------------------");
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
